﻿using Zen4SyncModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Zen4SyncModel.Test
{
    /// <summary>
    ///Classe de test pour IEntityProviderTest, destinée à contenir tous
    ///les tests unitaires IEntityProviderTest
    ///</summary>
    [TestClass()]
    public class IEntityProviderTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Obtient ou définit le contexte de test qui fournit
        ///des informations sur la série de tests active ainsi que ses fonctionnalités.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Attributs de tests supplémentaires
        // 
        //Vous pouvez utiliser les attributs supplémentaires suivants lorsque vous écrivez vos tests :
        //
        //Utilisez ClassInitialize pour exécuter du code avant d'exécuter le premier test dans la classe
        [ClassInitialize()]
        public static void MyClassInitialize( TestContext testContext )
        {
            using ( Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities() )
            {
                z4sEntities.sp_z4s_purge_database( true );
                z4sEntities.sp_z4s_insert_reference_data();
                z4sEntities.sp_z4s_insert_test_data_IEntityProvider();
            }
        }
        //
        //Utilisez ClassCleanup pour exécuter du code après que tous les tests ont été exécutés dans une classe
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Utilisez TestInitialize pour exécuter du code avant d'exécuter chaque test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Utilisez TestCleanup pour exécuter du code après que chaque test a été exécuté
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        internal virtual IEntityProvider CreateIEntityProvider()
        {
            IEntityProvider target = EntityProviderFactory.Instance;
            return target;
        }

        /// <summary>
        ///Test pour GetTestSessionDetails
        ///</summary>
        [TestMethod()]
        public void GetTestSessionDetailsTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid testSessionId = new Guid( "2C3C988A-675C-42D1-ACC5-D111E04D1F88" );
            Guid testServerId = new Guid( "4C439FF8-EE20-46C8-959A-250170B231F6" );
            List<Guid> expected = new List<Guid>() { new Guid( "87843D09-C873-45DA-8E0E-B66A30D719A6" ) };
            List<clientSession> actual;
            actual = target.GetTestSessionDetails( testSessionId, testServerId );

            Assert.AreEqual( expected.Count, actual.Count );
            foreach ( clientSession clientSession in actual )
            {
                if ( !expected.Contains( clientSession.clientSession_id ) )
                {
                    Assert.Fail();
                }
            }
        }

        /// <summary>
        ///Test pour GetSyncSession
        ///</summary>
        [TestMethod()]
        public void GetSyncSessionTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid syncSessionId = new Guid( "2B2BE227-2C90-42F8-9332-B3219C848B97" );
            syncSession actual;
            actual = target.GetSyncSession( syncSessionId );
            Assert.AreEqual( syncSessionId, actual.syncSession_id );
        }

        /// <summary>
        ///Test pour GetActivity
        ///</summary>
        [TestMethod()]
        public void GetActivityTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid activityId = new Guid( "1275E750-951D-4F31-A1A4-1E9CF5A4D722" );
            activity actual;
            actual = target.GetActivity( activityId );
            Assert.AreEqual( activityId, actual.activity_id );
        }

        /// <summary>
        ///Test pour GetMefExecution
        ///</summary>
        [TestMethod()]
        public void GetMefExecutionTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid mefExecutionId = new Guid( "9774766B-F49A-46B9-870A-8203D7F04B1C" );
            mefExecution actual;
            actual = target.GetMefExecution( mefExecutionId );
            Assert.AreEqual( mefExecutionId, actual.mefExecution_id );
        }

        /// <summary>
        ///Test pour GetSqlServerCheckData
        ///</summary>
        [TestMethod()]
        public void GetSqlServerCheckDataTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlServerCheckDataId = new Guid( "29FC5A45-F0F1-41AC-9E49-FC8AAB7827FE" );
            sqlServerCheckData actual;
            actual = target.GetSqlServerCheckData( sqlServerCheckDataId );
            Assert.AreEqual( sqlServerCheckDataId, actual.sqlServerCheckData_id );
        }

        /// <summary>
        ///Test pour GetSqlServerExecution
        ///</summary>
        [TestMethod()]
        public void GetSqlServerExecutionTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlServerExecutionId = new Guid( "E4782372-3F36-4468-9571-DE3E808932DB" );
            sqlServerExecution actual;
            actual = target.GetSqlServerExecution( sqlServerExecutionId );
            Assert.AreEqual( sqlServerExecutionId, actual.sqlServerExecution_id );
        }

        /// <summary>
        ///Test pour GetSqlServerExecutionContext
        ///</summary>
        [TestMethod()]
        public void GetSqlServerExecutionContextTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlServerExecutionContextId = new Guid( "22B3D012-7AC2-47BD-9D44-E76919F0C51A" );
            sqlServerExecutionContext actual;
            actual = target.GetSqlServerExecutionContext( sqlServerExecutionContextId );
            Assert.AreEqual( sqlServerExecutionContextId, actual.sqlServerExecutionContext_id );
        }

        /// <summary>
        ///Test pour GetSqlceBackup
        ///</summary>
        [TestMethod()]
        public void GetSqlceBackupTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlceBackupId = new Guid( "9F0F8A74-6F59-41EF-A283-E0C8409C57AD" );
            sqlceBackup actual;
            actual = target.GetSqlceBackup( sqlceBackupId );
            Assert.AreEqual( sqlceBackupId, actual.sqlceBackup_id );
        }

        /// <summary>
        ///Test pour GetSqlceCheckData
        ///</summary>
        [TestMethod()]
        public void GetSqlceCheckDataTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlceCheckDataId = new Guid( "10B76474-A7B8-42B9-9A04-501E9E917018" );
            sqlceCheckData actual;
            actual = target.GetSqlceCheckData( sqlceCheckDataId );
            Assert.AreEqual( sqlceCheckDataId, actual.sqlceCheckData_id );
        }

        /// <summary>
        ///Test pour GetSqlceExecution
        ///</summary>
        [TestMethod()]
        public void GetSqlceExecutionTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlceExecutionId = new Guid( "BE915A1D-191E-4766-B945-339F1F5E9574" );
            sqlceExecution actual;
            actual = target.GetSqlceExecution( sqlceExecutionId );
            Assert.AreEqual( sqlceExecutionId, actual.sqlceExecution_id );
        }

        /// <summary>
        ///Test pour GetSqlceExecutionContext
        ///</summary>
        [TestMethod()]
        public void GetSqlceExecutionContextTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlceExecutionContextId = new Guid( "B61D4C74-3CA4-4AE4-BECB-34B1818236FD" );
            sqlceExecutionContext actual;
            actual = target.GetSqlceExecutionContext( sqlceExecutionContextId );
            Assert.AreEqual( sqlceExecutionContextId, actual.sqlceExecutionContext_id );
        }

        /// <summary>
        ///Test pour GetSqlceCheckDataContext
        ///</summary>
        [TestMethod()]
        public void GetSqlceCheckDataContextTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlceCheckDataContextId = new Guid( "A574EE4F-F614-46B9-9B4B-B505195C630D" );
            sqlceCheckDataContext actual;
            actual = target.GetSqlceCheckDataContext( sqlceCheckDataContextId );
            Assert.AreEqual( sqlceCheckDataContextId, actual.sqlceCheckDataContext_id );
        }

        /// <summary>
        ///Test pour GetSqlceBackupContext
        ///</summary>
        [TestMethod()]
        public void GetSqlceBackupContextTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlceBackupContextId = new Guid( "C3644FD9-EBEE-492E-89F7-74F468BCE6D5" );
            sqlceBackupContext actual;
            actual = target.GetSqlceBackupContext( sqlceBackupContextId );
            Assert.AreEqual( sqlceBackupContextId, actual.sqlceBackupContext_id );
        }

        /// <summary>
        ///Test pour GetSqlServerCheckDataContext
        ///</summary>
        [TestMethod()]
        public void GetSqlServerCheckDataContextTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid sqlServerCheckDataContextId = new Guid( "DFF6F7B3-1A3F-4FDE-A439-15BFD0EE0679" );
            sqlServerCheckDataContext actual;
            actual = target.GetSqlServerCheckDataContext( sqlServerCheckDataContextId );
            Assert.AreEqual( sqlServerCheckDataContextId, actual.sqlServerCheckDataContext_id );
        }

        /// <summary>
        ///Test pour GetMefExecutionContext
        ///</summary>
        [TestMethod()]
        public void GetMefExecutionContextTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid mefExecutionContextId = new Guid( "40D9B3A2-A775-4404-83D0-8E630CB1CEB6" );
            mefExecutionContext actual;
            actual = target.GetMefExecutionContext( mefExecutionContextId );
            Assert.AreEqual( mefExecutionContextId, actual.mefExecutionContext_id );
        }

        /// <summary>
        ///Test pour GetTestServer
        ///</summary>
        [TestMethod()]
        public void GetTestServerTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid testServerId = new Guid("4C439FF8-EE20-46C8-959A-250170B231F6");
            testServer actual;
            actual = target.GetTestServer( testServerId );
            Assert.AreEqual( testServerId, actual.testServer_id );
        }

        /// <summary>
        ///Test pour getClientSessions
        ///</summary>
        [TestMethod()]
        public void getClientSessionsTest()
        {
            IEntityProvider target = CreateIEntityProvider();
            Guid testSessionId = new Guid( "2C3C988A-675C-42D1-ACC5-D111E04D1F88" );
            List<Guid> expected = new List<Guid>()
            {
                new Guid("87843D09-C873-45DA-8E0E-B66A30D719A6"),
                new Guid("394D95DC-FA1B-483F-B889-7712D6F8F614")
            };
            List<clientSession> actual;
            actual = target.getClientSessions( testSessionId );
            Assert.AreEqual( expected.Count, actual.Count );
            foreach ( clientSession clientSession in actual )
            {
                if ( !expected.Contains( clientSession.clientSession_id ) )
                {
                    Assert.Fail();
                }
            }
        }
    }
}
